package com.soundplus.app.shp04.Common;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.soundplus.app.shp04.R;

import java.util.List;

public class CommonMenuListAdapter extends BaseAdapter {
    Context context;
    List<String> menuItemList;
    LayoutInflater inflater;

    public CommonMenuListAdapter(Context context, List<String> menuItemList) {
        this.context = context;
        this.menuItemList = menuItemList;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return menuItemList.size();
    }

    @Override
    public String getItem(int i) {
        return menuItemList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewGroup vg;

        if (view != null) {
            vg = (ViewGroup) view;
        } else {
            vg = (ViewGroup) inflater.inflate(R.layout.common_menu_item, null);
        }

        final TextView name = vg.findViewById(R.id.tv_item_name);
        name.setText(getItem(i));
        return vg;
    }
}
